﻿//-----------------------------------------------------------------------
// <copyright file="RuleSetInfo.cs" company="tuliprules.org">
//     Copyright (c) 2010 tuplelister, tuliprules.org.
// </copyright>
// <summary>This is the RuleSetInfo class.</summary>
//-----------------------------------------------------------------------

namespace Tulip.Rules
{
    using System;

    /// <summary>
    /// Provides metadata to describe rule set.
    /// </summary>
    public class RuleSetInfo
    {
        /// <summary>
        /// The version specifier for the rule set.
        /// </summary>
        private Version version;

        /// <summary>
        /// Initializes a new instance of the RuleSetInfo class.
        /// </summary>
        public RuleSetInfo()
        {
            return;
        }

        /// <summary>
        /// Initializes a new instance of the RuleSetInfo class.
        /// </summary>
        /// <param name="name">
        /// Name of the rule set.
        /// </param>
        public RuleSetInfo(string name)
        {
            this.Name = name;
        }

        /// <summary>
        /// Initializes a new instance of the RuleSetInfo class.
        /// </summary>
        /// <param name="name">
        /// Name of the rule set.
        /// </param>
        /// <param name="majorVersion">
        /// The major version component of the version number.
        /// </param>
        /// <param name="minorVersion">
        /// The minor version component of the version number.
        /// </param>
        /// <param name="build">
        /// The build component of the version number.
        /// </param>
        /// <param name="revision">
        /// The revision component of the version number.
        /// </param>
        public RuleSetInfo(string name, int majorVersion, int minorVersion, int build, int revision)
        {
            this.Name = name;
            this.MajorVersion = majorVersion;
            this.MinorVersion = minorVersion;
            this.Build = build;
            this.Revision = revision;
        }

        /// <summary>
        /// Initializes a new instance of the RuleSetInfo class.
        /// </summary>
        /// <param name="name">
        /// Name of the rule set.
        /// </param>
        /// <param name="version">
        /// The version specifer for the rule set.
        /// </param>
        public RuleSetInfo(string name, Version version)
        {
            this.Name = name;
            this.Version = version;
        }

        /// <summary>
        /// Gets or sets the build component of the version number.
        /// </summary>
        /// <value>
        /// The build component of the version number.
        /// </value>
        public int Build { get; set; }

        /// <summary>
        /// Gets or sets the major version component of the version number.
        /// </summary>
        /// <value>
        /// The major version component of the version number.
        /// </value>
        public int MajorVersion { get; set; }

        /// <summary>
        /// Gets or sets the minor version component of the version number.
        /// </summary>
        /// <value>
        /// The minor version component of the version number.
        /// </value>
        public int MinorVersion { get; set; }

        /// <summary>
        /// Gets or sets the name of the rule.
        /// </summary>
        /// <value>
        /// The name of the rule.
        /// </value>
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the revision component of the version number.
        /// </summary>
        /// <value>
        /// The revision component of the version number.
        /// </value>
        public int Revision { get; set; }

        /// <summary>
        /// Gets the version number.
        /// </summary>
        /// <value>
        /// The version number.
        /// </value>
        public Version Version
        {
            get
            {
                return this.version ?? (this.version = new Version(this.MajorVersion, this.MinorVersion, this.Build, this.Revision));
            }

            private set
            {
                this.version = value;
                this.MajorVersion = value.Major;
                this.MinorVersion = value.Minor;
                this.Build = value.Build;
                this.Revision = value.Revision;
            }
        }

        /// <summary>
        /// Gets or sets a parser for the rule set.
        /// </summary>
        /// <value>
        /// A parser for the rule set.
        /// </value>
        public IRuleSetParser RuleParser { get; set; }
    }
}
